package cn.fl.capital.service.impl;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.capital.condition.CapAccBalanceQueryCondition;
import cn.fl.capital.dto.CapAccBalanceDTO;
import cn.fl.capital.service.ICapAccBalanceApiService;
import cn.fl.capital.service.ICapAccBalanceService;
import cn.fl.capital.transform.CapAccBalanceVOTransform;
import cn.fl.capital.vo.CapAccBalanceVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 账务结余（车立行） 客户端服务层接口实现
 * 业务层方法名称前缀：
 * 新增：add*
 * 删除：remove*
 * 修改：modify*
 * 批量：batch*
 * 查询对象：select* get*
 * 查询集合：search*
 */
@Service
public class CapAccBalanceServiceImpl implements ICapAccBalanceService {

	/**
     * 日志
     */
    @SuppressWarnings("unused")
    private static final Logger logger = LoggerFactory.getLogger(CapAccBalanceServiceImpl.class);
	
	/**
	 * 账务结余（车立行） 暴露服务
	 */
	@Autowired
	private ICapAccBalanceApiService capAccBalanceApiService;
	/**
     * 数据字典服务
     */
    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
        CapAccBalanceQueryCondition condition=null;
        if(null == page) {
            page = new Pager();
            page.setCondition(new CapAccBalanceQueryCondition());
        }
		condition=(CapAccBalanceQueryCondition)page.getCondition();
        condition.setSysCd(CurrentThreadContext.getCurrentSysCd());//当前系统代码
        condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());//当前机构代码
        condition.setUsrId(CurrentThreadContext.getCurrentUserId());//当前用户ID
		page=this.capAccBalanceApiService.searchCapAccBalanceListPage(page);
		if(CollectionUtils.isNotEmpty(page.getResultList())){
            List<CapAccBalanceVO> voList=CapAccBalanceVOTransform.toVOList((List<CapAccBalanceDTO>)page.getResultList());
            //this.setDictData(voList);
            page.setResultList(voList);
        }
        return page;
	}
	
}
